`
https://leetcode.cn/problems/the-k-strongest-values-in-an-array/
`

/**
 * @param {number[]} arr
 * @param {number} k
 * @return {number[]}
 */
var getStrongest = function (arr, k) {
  arr.sort((a, b) => a - b)
  const n = arr.length
  const m = arr[Math.floor((n - 1) / 2)]
  const res = Array(k)
  let l = 0, r = n - 1
  for (let i = 0; i < k; i++) {
    if (Math.abs(arr[l] - m) > Math.abs(arr[r] - m)) {
      res[i] = arr[l++]
    } else {
      res[i] = arr[r--]
    }
  }
  return res
};